<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script src="https://cdn.bootcss.com/vue/2.5.16/vue.js"></script>
    <script src="vue-router.js"></script>
</head>
<body>
<div id="hd">
    <router-link to="/content">aaaa</router-link>
    <router-view></router-view>
</div>
<script type="text/x-template" id="tp">
<div>
    {{id}}
    <button>检测</button>
</div>

</script>
<script>
    const hdnew={
        template:'#tp',
        data(){
            return {
                id:0
            }
        },
        mounted(){
            this.id=this.$route.params.id;
            if(!this.id){
                this.id=1
            }
        }
    }
    let route=new VueRouter({
        routes:[
            {path:'/content/:id?',component:hdnew}
        ]
    })
    var app=new Vue({
        el:'#hd',
        data:{},
        router:route
    })
</script>
</body>
</html>